import { Module } from '@nestjs/common';
import { UploadService } from './upload.service';
import { UploadController } from './upload.controller';
import { MulterModule } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { extname, join } from 'path';

@Module({
  imports:[MulterModule.register({
    storage:diskStorage({
      destination:join(__dirname,'../images'), //文件的存放位置
      filename(req, file, callback) {
        const fileName = `${new Date().getTime() + extname(file.originalname)}`;//后缀名:originalname
        return callback(null,fileName);
      }
    })
  })],
  controllers: [UploadController],
  providers: [UploadService],
})
export class UploadModule {}
